fix(tui): stop completion mangling column names that need quoting (T1) - #57
Merged
Merged
Conversation
Completion had two independent backward scanners from the cursor. The
parser decided *what* to suggest; extract_partial_word_at_cursor in
text_operations.rs independently decided *what span to replace*. They
disagreed whenever quotes or dots were involved.
On data/countries.csv (name.common, idd.root, translations.ara.official):
SELECT name.<tab> offered Contains('') instead of the columns
SELECT name.com<tab> offered nothing at all
SELECT "na<tab> produced SELECT name.common" (quote eaten)
SELECT na<tab><tab> produced SELECT "name.commonname.official"
So every column that has to be quoted was effectively unreachable by
completion, and cycling corrupted the buffer.
Introduce src/sql/completion_token.rs: one quote- and dot-aware scanner
both halves share, handling an open quote, a cursor just past a closing
quote, and a bare identifier where dots are part of the name. Add
ParseResult::replace_start so the parser hands the editor the byte span
to splice over instead of the editor guessing, threaded through
HybridResult and CompletionState so it survives Tab cycling.
complete_dotted_column resolves dotted text that prefixes a real column;
text matching no column (capital.Con, 1.5, t.name) falls through to the
existing method-call handling unchanged.
Also replaces ~55 lines of tangled quote-matching in the suggestion
filter with a single unquoted comparison, and deletes the now-unused
extract_partial_word_at_cursor - leaving a superseded duplicate scanner
in place is how this regresses.
Adds docs/TUI_FEATURES.md, a T-numbered book of work for the interactive
editor alongside the P (parity) and R (refactoring) logs. The TUI has no
equivalent of the parity harness, so its defects only surface in use;
T2-T6 record what this fix uncovered, including that get_property_type
is still a hardcoded list of trade-desk column names.
Tests: tests/dotted_column_completion.rs (12) covers both halves - what
is suggested and what the buffer ends up containing - plus 9 unit tests
for the scanner. Full suite green, no new clippy warnings.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0152wRProARq2WGPss4698iY
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Completion had two independent backward scanners from the cursor. The parser decided what to suggest; extract_partial_word_at_cursor in text_operations.rs independently decided what span to replace. They disagreed whenever quotes or dots were involved.
On data/countries.csv (name.common, idd.root, translations.ara.official):
SELECT name. offered Contains('') instead of the columns
SELECT name.com offered nothing at all
SELECT "na produced SELECT name.common" (quote eaten)
SELECT na produced SELECT "name.commonname.official"
So every column that has to be quoted was effectively unreachable by completion, and cycling corrupted the buffer.
Introduce src/sql/completion_token.rs: one quote- and dot-aware scanner both halves share, handling an open quote, a cursor just past a closing quote, and a bare identifier where dots are part of the name. Add ParseResult::replace_start so the parser hands the editor the byte span to splice over instead of the editor guessing, threaded through HybridResult and CompletionState so it survives Tab cycling.
complete_dotted_column resolves dotted text that prefixes a real column; text matching no column (capital.Con, 1.5, t.name) falls through to the existing method-call handling unchanged.
Also replaces ~55 lines of tangled quote-matching in the suggestion filter with a single unquoted comparison, and deletes the now-unused extract_partial_word_at_cursor - leaving a superseded duplicate scanner in place is how this regresses.
Adds docs/TUI_FEATURES.md, a T-numbered book of work for the interactive editor alongside the P (parity) and R (refactoring) logs. The TUI has no equivalent of the parity harness, so its defects only surface in use; T2-T6 record what this fix uncovered, including that get_property_type is still a hardcoded list of trade-desk column names.
Tests: tests/dotted_column_completion.rs (12) covers both halves - what is suggested and what the buffer ends up containing - plus 9 unit tests for the scanner. Full suite green, no new clippy warnings.
Claude-Session: https://claude.ai/code/session_0152wRProARq2WGPss4698iY